* ============================================================================ *
* PROJECT:		The bottom-up spillover effect for radical right parties
* AUTHOR: 		Ka Ming Chan
* DATE:			2022-04-21
* ============================================================================ *

* ---------------------------------------------------------------------------- *
* Settings and Open Data
* ---------------------------------------------------------------------------- *
cd ""
use "individual_level.dta", replace

//ssc install plotplain
describe
sum
set scheme plotplain
tsset id wave 
drop if tr_lt==2  // drop Already treated states


***********************
* Viability mechanism *
***********************
* ------------------------------------------------------------------------------
* DV: probability to enter federal parliament
* ------------------------------------------------------------------------------
eststo ife_pr_AfD: xtreg pr_AfD_ tr_lt##i.wave##AfD2017 AfD_pi_ tax_ego_ mig_ego_ polint_, fe 
estadd local fixedi "YES", replace
predict fe_pr_AfD, u
tabulate tr_lt if AfD2017==1, summarize(fe_pr_AfD)
margins if tr_lt==0 & AfD2017==1, exp(predict(xb) + 0.20008652) at(wave=(5 6 7))  noestimcheck saving(stateutr, replace) 
margins if tr_lt==1 & AfD2017==1, exp(predict(xb) + 0.21163379) at(wave=(5 6 7))  noestimcheck saving(statetr, replace)
grstyle init
grstyle color p1 black
combomarginsplot stateutr statetr, labels("Control states" "Treated states") savefile(pr_AfD, replace)
mplotoffset using pr_AfD, xtitle("Wave") xlabel(1(1)7) xlabel(1(1)7) xline(2.5,  lpattern(solid) lc(gs10%50) lwidth(vvvthick)) ytitle("Pr(AfD entering federal parliament)", size(small)) ylabel(0.4(0.1)1) title("") ///
	legend(position(6) r(1))  plot1opts(lpattern(shortdash) lcolor("0 158 224") mcolor("0 158 224")) ci1opts(lcolor("0 158 224")) ///
	plot2opts(lcolor("0 158 224") mcolor("0 158 224")) ci2opts(lcolor("0 158 224")) saving(pr_AfD_AfDvoters, replace)  

* coefplot
coefplot ife_pr_AfD, keep(1.tr_lt#6.wave#1.AfD2017 1.tr_lt#7.wave#1.AfD2017) baselevels  ///
	p1(msymbol(O))  levels(95 90)  ciopts(lwidth(*0.5 *2)) ///
	ytitle(Coefficient, size(small)) vertical yline(0) ylabel(-0.1(0.05)0.1) xtitle(, size(small))  xlabel(,labsize(vsmall)) ///
	coeflabels (1.tr_lt#6.wave#1.AfD2017="AfD{&lowast}tr{&lowast}w6" 1.tr_lt#7.wave#1.AfD2017="AfD{&lowast}tr{&lowast}w7") ///
	legend(off) saving(coef_pr_AfD_AfDvoters, replace)

* ------------------------------------------------------------------------------
* Figure C.1. Viability mechanism among non-AfD voters
tabulate tr_lt if AfD2017==0, summarize(fe_pr_AfD)
margins if tr_lt==0 & AfD2017==0, exp(predict(xb) - 0.01742393) at(wave=(5 6 7))  noestimcheck saving(stateutr, replace) 
margins if tr_lt==1 & AfD2017==0, exp(predict(xb) - 0.03957534) at(wave=(5 6 7))  noestimcheck saving(statetr, replace)
grstyle init
grstyle color p1 black
combomarginsplot stateutr statetr, labels("Control states" "Treated states") savefile(pr_AfD_nonAfDvoters, replace)
mplotoffset using pr_AfD_nonAfDvoters, xtitle("Wave") xlabel(1(1)7)  xlabel(1(1)7)  xline(2.5,  lpattern(solid) lc(gs10%50) lwidth(vvvthick)) ytitle("Pr(AfD entering federal parliament)", size(small)) ylabel(0.4(0.1)1) title("") ///
	legend(position(6) r(1))  plot1opts(lpattern(shortdash) lcolor(black) mcolor(black)) ci1opts(lcolor(black)) ///
	plot2opts(lcolor(black) mcolor(black)) ci2opts(lcolor(black)) saving(pr_AfD_nonAfDvoters, replace)  

coefplot ife_pr_AfD, keep(1.tr_lt#6.wave 1.tr_lt#7.wave) baselevels  ///
	p1(msymbol(O))  levels(95 90)  ciopts(lwidth(*0.5 *2)) ///
	ytitle(Coefficient, size(small)) vertical yline(0) ylabel(-0.1(0.05)0.1) xtitle(, size(small))  xlabel(,labsize(vsmall)) ///
	coeflabels (1.tr_lt#6.wave="tr{&lowast}w6" 1.tr_lt#7.wave="tr{&lowast}w7") ///
	legend(off) saving(coef_pr_AfD_nonAfDvoters, replace)
	
graph combine pr_AfD_nonAfDvoters.gph coef_pr_AfD_nonAfDvoters.gph, row(1)
graph export "Fig C1.png", replace

* ------------------------------------------------------------------------------
* DV: vote preference for AfD 
* ------------------------------------------------------------------------------
eststo ife_AfD_votepref_cs: xtreg AfD_votepref_cs_ tr_lt##i.wave##AfD2017 AfD_pi_ tax_ego_ mig_ego_ polint_, fe 
estadd local fixedi "YES", replace
predict fe_AfD_votepref_cs, u
tabulate tr_lt if AfD2017==1, summarize(fe_AfD_votepref_cs)
margins if tr_lt==0 & AfD2017==1, exp(predict(xb) + 0.53655596) at(wave=(1 3 4 5 6 7)) noestimcheck saving(stateutr, replace) 
margins if tr_lt==1 & AfD2017==1, exp(predict(xb) + 0.55872974) at(wave=(1 3 4 5 6 7)) noestimcheck saving(statetr, replace)
grstyle init
grstyle color p1 black
combomarginsplot stateutr statetr, labels("Control states" "Treated states") savefile(AfD_votepref_cs, replace)
	mplotoffset using AfD_votepref_cs, xtitle("Wave") xlabel(1(1)7)  xline(2.5,  lpattern(solid) lc(gs10%50) lwidth(vvvthick)) ytitle("Vote preference: AfD", size(small)) ylabel(0.4(0.1)1)  title("") ///
	legend(position(6) r(1)) plot1opts(lpattern(shortdash) lcolor("0 158 224") mcolor("0 158 224")) ci1opts(lcolor("0 158 224")) ///
	plot2opts(lcolor("0 158 224") mcolor("0 158 224")) ci2opts(lcolor("0 158 224")) saving(AfD_votepref_cs_AfDvoters, replace)  

* coefplot
coefplot ife_AfD_votepref_cs, keep(1.tr_lt#3.wave#1.AfD2017 1.tr_lt#4.wave#1.AfD2017 1.tr_lt#5.wave#1.AfD2017 1.tr_lt#6.wave#1.AfD2017 1.tr_lt#7.wave#1.AfD2017) baselevels  ///
	p1(msymbol(O))  levels(95 90)  ciopts(lwidth(*0.5 *2)) ///
	ytitle(Coefficient, size(small)) vertical yline(0) ylabel(-0.1(0.05)0.1) xtitle(, size(small)) xlabel(,labsize(vsmall)) ///
	coeflabels (1.tr_lt#3.wave#1.AfD2017="AfD{&lowast}tr{&lowast}w3" 1.tr_lt#4.wave#1.AfD2017="AfD{&lowast}tr{&lowast}w4" 1.tr_lt#5.wave#1.AfD2017="AfD{&lowast}tr{&lowast}w5" 1.tr_lt#6.wave#1.AfD2017="AfD{&lowast}tr{&lowast}w6" 1.tr_lt#7.wave#1.AfD2017="AfD{&lowast}tr{&lowast}w7") legend(off) saving(coef_AfD_votepref_cs_AfDvoters, replace)


graph combine pr_AfD_AfDvoters.gph coef_pr_AfD_AfDvoters.gph AfD_votepref_cs_AfDvoters.gph coef_AfD_votepref_cs_AfDvoters.gph, row(2)
graph export "Fig 4.png", replace	

************************
* Visibility mechanism *
************************
* ------------------------------------------------------------------------------
* DV: exposure to AfD campaign
* ------------------------------------------------------------------------------
eststo ife_campaign_AfD: xtreg campaign_AfD_ tr_lt##i.wave##AfD2017 AfD_pi_ tax_ego_ mig_ego_ polint_, fe 
estadd local fixedi "YES", replace
predict fe_campaign_AfD, u
tabulate tr_lt if AfD2017==1, summarize(fe_campaign_AfD)
margins if tr_lt==0 & AfD2017==1, exp(predict(xb) + 0.1718414) at(wave=(4 5 6 7))  noestimcheck saving(stateutr, replace) 
margins if tr_lt==1 & AfD2017==1, exp(predict(xb) + 0.17516025) at(wave=(4 5 6 7))  noestimcheck saving(statetr, replace)
grstyle init
grstyle color p1 black
combomarginsplot stateutr statetr, labels("Control states" "Treated states" "Already treated states") savefile(campaign_AfD, replace)
mplotoffset using campaign_AfD, xtitle("Wave") xlabel(1(1)7)  xline(2.5,  lpattern(solid) lc(gs10%50) lwidth(vvvthick)) ytitle("Exposure to AfD's campaign", size(small)) ylabel(0.2(0.1)1)  title("") ///
	legend(position(6) r(1)) plot1opts(lpattern(shortdash) lcolor("0 158 224") mcolor("0 158 224")) ci1opts(lcolor("0 158 224")) ///
	plot2opts(lcolor("0 158 224") mcolor("0 158 224")) ci2opts(lcolor("0 158 224")) saving(campaign_AfD_AfDvoters, replace)  


* coefplot
coefplot ife_campaign_AfD, keep(1.tr_lt#5.wave#1.AfD2017 1.tr_lt#6.wave#1.AfD2017 1.tr_lt#7.wave#1.AfD2017) baselevels  ///
	p1(msymbol(O))  levels(95 90)  ciopts(lwidth(*0.5 *2)) ///
	ytitle(Coefficient, size(small)) vertical yline(0) ylabel(-0.2(0.1)0.2) xtitle(, size(small)) xlabel(,labsize(vsmall)) ///
	coeflabels (1.tr_lt#5.wave#1.AfD2017="AfD{&lowast}tr{&lowast}w5" 1.tr_lt#6.wave#1.AfD2017="AfD{&lowast}tr{&lowast}w6"  1.tr_lt#7.wave#1.AfD2017="AfD{&lowast}tr{&lowast}w7") ///
	legend(off) saving(coef_campaign_AfD_AfDvoters, replace)

* ------------------------------------------------------------------------------
* DV: AfD's immigration position
* ------------------------------------------------------------------------------
eststo ife_know_AfD_immig: xtreg know_AfD_immig_ tr_lt##i.wave##AfD2017 AfD_pi_ tax_ego_ mig_ego_ polint_, fe 
estadd local fixedi "YES", replace
predict fe_know_AfD_immig, u
tabulate tr_lt if AfD2017==1, summarize(fe_know_AfD_immig)
margins if tr_lt==0 & AfD2017==1, exp(predict(xb) + 0.07206722) at(wave=(2 4 7))  noestimcheck saving(stateutr, replace) 
margins if tr_lt==1 & AfD2017==1, exp(predict(xb) + 0.04843131) at(wave=(2 4 7))  noestimcheck saving(statetr, replace)
grstyle init
grstyle color p1 black
combomarginsplot stateutr statetr, labels("Control states" "Treated states" "Already treated states") savefile(know_AfD_immig, replace)
mplotoffset using know_AfD_immig, xtitle("Wave") xlabel(1(1)7)  xline(2.5,  lpattern(solid) lc(gs10%50) lwidth(vvvthick)) ytitle("Knowing AfD's immigration position", size(small)) ylabel(0.2(0.1)1)  title("") ///
	legend(position(6) r(1)) plot1opts(lpattern(shortdash) lcolor("0 158 224") mcolor("0 158 224")) ci1opts(lcolor("0 158 224")) ///
	plot2opts(lcolor("0 158 224") mcolor("0 158 224")) ci2opts(lcolor("0 158 224")) saving(know_AfD_immig_AfDvoters, replace)  

* coefplot
coefplot ife_know_AfD_immig, keep(1.tr_lt#4.wave#1.AfD2017 1.tr_lt#7.wave#1.AfD2017) baselevels  ///
	p1(msymbol(O))  levels(95 90)  ciopts(lwidth(*0.5 *2)) ///
	ytitle(Coefficient, size(small)) vertical yline(0) ylabel(-0.2(0.1)0.2) xtitle(, size(small)) xlabel(,labsize(vsmall)) ///
	coeflabels (1.tr_lt#2.wave#1.AfD2017="AfD{&lowast}tr{&lowast}w2" 1.tr_lt#4.wave#1.AfD2017="AfD{&lowast}tr{&lowast}w4"  1.tr_lt#7.wave#1.AfD2017="AfD{&lowast}tr{&lowast}w7") ///
	legend(off) saving(coef_know_AfD_immig_AfDvoters, replace)

graph combine campaign_AfD_AfDvoters.gph coef_campaign_AfD_AfDvoters.gph know_AfD_immig_AfDvoters.gph coef_know_AfD_immig_AfDvoters.gph, row(2)
graph export "Fig 5.png", replace		

**************************
* Legitimation mechanism *
**************************
* ------------------------------------------------------------------------------
* DV: rating of AfD 
* ------------------------------------------------------------------------------
eststo ife_rate_AfD: xtreg rate_AfD_ tr_lt##i.wave##AfD2017 AfD_pi_ tax_ego_ mig_ego_ polint_, fe 
estadd local fixedi "YES", replace
predict fe_rate_AfD, u
tabulate tr_lt if AfD2017==1, summarize(fe_rate_AfD)
margins if tr_lt==0 & AfD2017==1, exp(predict(xb) + 4.6932496) at(wave=(1(1)7))  noestimcheck saving(stateutr, replace) 
margins if tr_lt==1 & AfD2017==1, exp(predict(xb) + 4.8025249) at(wave=(1(1)7))  noestimcheck saving(statetr, replace)
grstyle init
grstyle color p1 black
combomarginsplot stateutr statetr, labels("Control states" "Treated states") savefile(rate_AfD, replace)
mplotoffset using rate_AfD, xtitle("Wave") xlabel(1(1)7) xline(2.5,  lpattern(solid) lc(gs10%50) lwidth(vvvthick)) ytitle("Rating of AfD") ylabel( 6 "0" 7 "1" 8 "2" 9 "3")  title("") ///
	legend(position(6) r(1)) plot1opts(lpattern(shortdash) lcolor("0 158 224") mcolor("0 158 224")) ci1opts(lcolor("0 158 224")) ///
	plot2opts(lcolor("0 158 224") mcolor("0 158 224")) ci2opts(lcolor("0 158 224")) saving(rate_AfD_AfDvoters, replace)  

* coefplot
coefplot ife_rate_AfD, keep(1.tr_lt#2.wave#1.AfD2017 1.tr_lt#3.wave#1.AfD2017 1.tr_lt#4.wave#1.AfD2017 1.tr_lt#5.wave#1.AfD2017 1.tr_lt#6.wave#1.AfD2017 1.tr_lt#7.wave#1.AfD2017) baselevels  ///
	p1(msymbol(O))  levels(95 90)  ciopts(lwidth(*0.5 *2)) ///
	ytitle(Coefficient, size(small)) vertical yline(0) ylabel(-0.4(0.2)0.8) xtitle(, size(small)) xlabel(,labsize(vsmall)) ///
	coeflabels (1.tr_lt#2.wave#1.AfD2017="AfD{&lowast}tr{&lowast}w2" 1.tr_lt#3.wave#1.AfD2017="AfD{&lowast}tr{&lowast}w3" 1.tr_lt#4.wave#1.AfD2017="AfD{&lowast}tr{&lowast}w4" 1.tr_lt#5.wave#1.AfD2017="AfD{&lowast}tr{&lowast}w5" 1.tr_lt#6.wave#1.AfD2017="AfD{&lowast}tr{&lowast}w6" 1.tr_lt#7.wave#1.AfD2017="AfD{&lowast}tr{&lowast}w7") legend(off) saving(coef_rate_AfD_AfDvoters, replace)

	
graph combine rate_AfD_AfDvoters.gph coef_rate_AfD_AfDvoters.gph, row(1)
graph export "Fig 6.png", replace	

	

* ------------------------------------------------------------------------------
* Table C.1. Viability mechanism, exposure mechanism and legitimation mechanism: fixed effect models
* ------------------------------------------------------------------------------
esttab ife_pr_AfD ife_AfD_votepref_cs ife_know_AfD_immig ife_campaign_AfD  ife_rate_AfD  ///
	using "Table C1.rtf", b(2) se(2) replace ///
	scalars ("N Observations" "N_g Number of respondents" "fixedi Individual FE" ) sfmt(0) ///
	label wide note onecell nobaselevels  noomitted nonumbers  lines varwidth(20) ///
	coeflabels(2.wave "wave 2" 3.wave "wave 3" 4.wave "wave 4" 5.wave "wave 5" 6.wave "wave 6" 7.wave "wave 7" ///
	1.tr_lt#2.wave "tr * wave 2" 1.tr_lt#3.wave "tr * wave 3" 1.tr_lt#4.wave "tr * wave 4" 	1.tr_lt#5.wave "tr * wave 5" 1.tr_lt#6.wave "tr * wave 6" 1.tr_lt#7.wave "tr * wave 7" ///
	2.wave#1.AfD2017 "AfD * wave 2" 3.wave#1.AfD2017 "AfD * wave 3" 4.wave#1.AfD2017 "AfD * wave 4" ///
	5.wave#1.AfD2017 "AfD * wave 5" 6.wave#1.AfD2017 "AfD * wave 6" 7.wave#1.AfD2017 "AfD * wave 7" ///
	1.tr_lt#2.wave#1.AfD2017 "tr * AfD * wave 2" 1.tr_lt#3.wave#1.AfD2017 "tr * AfD * wave 3" 1.tr_lt#4.wave#1.AfD2017 "tr * AfD * wave 4" 	///
	1.tr_lt#5.wave#1.AfD2017 "tr * AfD * wave 5" 1.tr_lt#6.wave#1.AfD2017 "tr * AfD * wave 6" 1.tr_lt#7.wave#1.AfD2017 "tr * AfD * wave 7") ///
	order (2.wave 3.wave 4.wave 5.wave 6.wave 7.wave 1.tr_lt#2.wave 1.tr_lt#3.wave 1.tr_lt#4.wave 1.tr_lt#5.wave 1.tr_lt#6.wave 1.tr_lt#7.wave ///
	2.wave#1.AfD2017 3.wave#1.AfD2017 4.wave#1.AfD2017 5.wave#1.AfD2017  6.wave#1.AfD2017 7.wave#1.AfD2017 ///
	1.tr_lt#2.wave#1.AfD2017  1.tr_lt#3.wave#1.AfD2017 1.tr_lt#4.wave#1.AfD2017 1.tr_lt#5.wave#1.AfD2017 1.tr_lt#6.wave#1.AfD2017 1.tr_lt#7.wave#1.AfD2017 ) ///
	mtitles("Model 1" "Model 2" "Model 3" "Model 4" "Model 5") modelwidth(4) ///
	star(+ 0.10 * 0.05 ** 0.01 *** 0.001) ///
	note ("Note: DV of Model 1: Perceived probability of AfD entering federal parliament;" ///
	"DV of Model 2: Intend to vote for AfD (dummy);" ///
	"DV of Model 3: Knowing AfD's immigration position (dummy);" ///
	"DV of Model 4: Receiving campaign information from AfD (dummy);" ///
	"DV of Model 5: Rating of AfD." ///
	"Entries are coefficients of fixed effect model.") ///
	title ("Table C.1. Viability mechanism, exposure mechanism and legitimation mechanism: fixed effect models") 

	
*********************
* Robustness checks *
*********************
* ------------------------------------------------------------------------------
* Rejecting campaign effect of subnational election and bandwagon effect
* ------------------------------------------------------------------------------
* ------------------------------------------------------------------------------
* Figure C.2. Placebo test: Rating of other parties
eststo ife_rate_CDU: xtreg rate_CDU tr_lt##i.wave##CDU2017 CDU_pi_ tax_ego_ mig_ego_ polint_, fe 
estadd local fixedi "YES", replace
predict fe_rate_CDU, u
tabulate tr_lt if CDU2017==1, summarize(fe_rate_CDU)
margins if tr_lt==0 & CDU2017==1, exp(predict(xb) + 2.5647024) at(wave=(1(1)7))  noestimcheck saving(stateutr, replace) 
margins if tr_lt==1 & CDU2017==1, exp(predict(xb) + 2.7924864) at(wave=(1(1)7))   noestimcheck  saving(statetr, replace)
combomarginsplot stateutr statetr, labels("Control states" "Treated states") savefile(rate_CDU, replace)
mplotoffset using rate_CDU, xtitle("Wave") xlabel(1(1)7) xline(2.5,  lpattern(solid) lc(gs10%50) lwidth(vvvthick)) ytitle("Rating of CDU") ylabel( 6 "0" 7 "1" 8 "2" 9 "3" 10 "4")  title("CDU voters") ///
	legend(position(6) row(1))  plot1opts(lpattern(shortdash) lcolor(black) mcolor(black)) ci1opts(lcolor(black)) ///
	plot2opts(lcolor(black) mcolor(black)) ci2opts(lcolor(black)) saving(rate_CDU, replace)   	

eststo ife_rate_SPD: xtreg rate_SPD tr_lt##i.wave##SPD2017 SPD_pi_ tax_ego_ mig_ego_ polint_, fe 
estadd local fixedi "YES", replace
predict fe_rate_SPD, u
tabulate tr_lt if SPD2017==1, summarize(fe_rate_SPD)
margins if tr_lt==0 & SPD2017==1, exp(predict(xb) + 1.7551256) at(wave=(1(1)7))  noestimcheck saving(stateutr, replace) 
margins if tr_lt==1 & SPD2017==1, exp(predict(xb) + 1.6151962) at(wave=(1(1)7))  noestimcheck  saving(statetr, replace)
combomarginsplot stateutr statetr, labels("Control states" "Treated states") savefile(rate_SPD, replace)
mplotoffset using rate_SPD, xtitle("Wave") xlabel(1(1)7) xline(2.5,  lpattern(solid) lc(gs10%50) lwidth(vvvthick)) ytitle("Rating of SPD") ylabel( 6 "0" 7 "1" 8 "2" 9 "3" 10 "4")  title("SPD voters") ///
	legend(position(6) row(1))  plot1opts(lpattern(shortdash) lcolor(plr1) mcolor(plr1)) ci1opts(lcolor(plr1)) ///
	plot2opts(lcolor(plr1) mcolor(plr1)) ci2opts(lcolor(plr1)) saving(rate_SPD, replace)   

eststo ife_rate_FDP: xtreg rate_FDP tr_lt##i.wave##FDP2017 FDP_pi_ tax_ego_ mig_ego_ polint_, fe 
estadd local fixedi "YES", replace
predict fe_rate_FDP, u
tabulate tr_lt if FDP2017==1, summarize(fe_rate_FDP)
margins if tr_lt==0 & FDP2017==1, exp(predict(xb) + 2.3187497) at(wave=(1(1)7))  noestimcheck saving(stateutr, replace) 
margins if tr_lt==1 & FDP2017==1, exp(predict(xb) + 2.3100761) at(wave=(1(1)7))  noestimcheck  saving(statetr, replace)
combomarginsplot stateutr statetr, labels("Control states" "Treated states") savefile(rate_FDP, replace)
mplotoffset using rate_FDP, xtitle("Wave") xlabel(1(1)7)  xline(2.5,  lpattern(solid) lc(gs10%50) lwidth(vvvthick)) ytitle("Rating of FDP") ylabel( 6 "0" 7 "1" 8 "2" 9 "3" 10 "4")   title("FDP voters") ///
	legend(position(6) row(1)) plot1opts(lpattern(shortdash) lcolor(ply1) mcolor(ply1)) ci1opts(lcolor(ply1)) ///
	plot2opts(lcolor(ply1) mcolor(ply1)) ci2opts(lcolor(ply1)) saving(rate_FDP, replace)   

eststo ife_rate_Gr: xtreg rate_Gr tr_lt##i.wave##Gr2017 Gr_pi_ tax_ego_ mig_ego_ polint_, fe 
estadd local fixedi "YES", replace
predict fe_rate_Gr, u
tabulate tr_lt if Gr2017==1, summarize(fe_rate_Gr)
margins if tr_lt==0 & Gr2017==1, exp(predict(xb) + 2.8255553) at(wave=(1(1)7))  noestimcheck saving(stateutr, replace) 
margins if tr_lt==1 & Gr2017==1, exp(predict(xb) + 2.7002495) at(wave=(1(1)7))  noestimcheck  saving(statetr, replace)
combomarginsplot stateutr statetr, labels("Control states" "Treated states") savefile(rate_Gr, replace)
mplotoffset using rate_Gr, xtitle("Wave") xlabel(1(1)7) xline(2.5,  lpattern(solid) lc(gs10%50) lwidth(vvvthick)) ytitle("Rating of Green") ylabel( 6 "0" 7 "1" 8 "2" 9 "3" 10 "4")  title("Green voters") ///
	legend(position(6) row(1)) plot1opts(lpattern(shortdash) lcolor(turquoise) mcolor(turquoise)) ci1opts(lcolor(turquoise)) ///
	plot2opts(lcolor(turquoise) mcolor(turquoise)) ci2opts(lcolor(turquoise)) saving(rate_Gr, replace)   


eststo ife_rate_LP: xtreg rate_LP tr_lt##i.wave##LP2017 LP_pi_ tax_ego_ mig_ego_ polint_, fe 
estadd local fixedi "YES", replace
predict fe_rate_LP, u
tabulate tr_lt if LP2017==1, summarize(fe_rate_LP)
margins if tr_lt==0 & LP2017==1, exp(predict(xb) + 2.7333882) at(wave=(1(1)7))  noestimcheck saving(stateutr, replace) 
margins if tr_lt==1 & LP2017==1, exp(predict(xb) + 2.9774292) at(wave=(1(1)7))  noestimcheck  saving(statetr, replace)
combomarginsplot stateutr statetr, labels("Control states" "Treated states") savefile(rate_LP, replace)
mplotoffset using rate_LP, xtitle("Wave") xlabel(1(1)7)  xline(2.5,  lpattern(solid) lc(gs10%50) lwidth(vvvthick)) ytitle("Rating of LP") ylabel( 6 "0" 7 "1" 8 "2" 9 "3" 10 "4")  title("LP voters") ///
	legend(position(6) row(1)) plot1opts(lpattern(shortdash) lcolor(pll1) mcolor(pll1)) ci1opts(lcolor(pll1)) ///
	plot2opts(lcolor(pll1) mcolor(pll1)) ci2opts(lcolor(pll1)) saving(rate_LP, replace)   

grc1leg rate_CDU.gph rate_SPD.gph rate_FDP.gph rate_Gr.gph rate_LP.gph, ycommon 
graph export "Fig C2.png", replace

* ------------------------------------------------------------------------------
* Figure C.3 Coefficient plots of placebo test: Rating of other parties
coefplot ife_rate_CDU, keep(1.tr_lt#2.wave#1.CDU2017 1.tr_lt#3.wave#1.CDU2017 1.tr_lt#4.wave#1.CDU2017 1.tr_lt#5.wave#1.CDU2017 1.tr_lt#6.wave#1.CDU2017 1.tr_lt#7.wave#1.CDU2017) baselevels  ///
	p1(msymbol(O))  levels(95 90)  ciopts(lwidth(*0.5 *2)) ///
	ytitle(Coefficient, size(small)) vertical yline(0) ylabel(-0.4(0.2)0.8) xtitle(, size(small)) xlabel(,labsize(vsmall) angle(45)) ///
	coeflabels (1.tr_lt#2.wave#1.CDU2017="CDU{&lowast}tr{&lowast}w2" 1.tr_lt#3.wave#1.CDU2017="CDU{&lowast}tr{&lowast}w3" 1.tr_lt#4.wave#1.CDU2017="CDU{&lowast}tr{&lowast}w4" 1.tr_lt#5.wave#1.CDU2017="CDU{&lowast}tr{&lowast}w5" 1.tr_lt#6.wave#1.CDU2017="CDU{&lowast}tr{&lowast}w6" 1.tr_lt#7.wave#1.CDU2017="CDU{&lowast}tr{&lowast}w7") legend(off) saving(coef_rate_CDU_CDUvoters, replace)
	
coefplot ife_rate_SPD, keep(1.tr_lt#2.wave#1.SPD2017 1.tr_lt#3.wave#1.SPD2017 1.tr_lt#4.wave#1.SPD2017 1.tr_lt#5.wave#1.SPD2017 1.tr_lt#6.wave#1.SPD2017 1.tr_lt#7.wave#1.SPD2017) baselevels  ///
	p1(msymbol(O))  levels(95 90)  ciopts(lwidth(*0.5 *2)) ///
	ytitle(Coefficient, size(small)) vertical yline(0) ylabel(-0.4(0.2)0.8) xtitle(, size(small)) xlabel(,labsize(vsmall) angle(45)) ///
	coeflabels (1.tr_lt#2.wave#1.SPD2017="SPD{&lowast}tr{&lowast}w2" 1.tr_lt#3.wave#1.SPD2017="SPD{&lowast}tr{&lowast}w3" 1.tr_lt#4.wave#1.SPD2017="SPD{&lowast}tr{&lowast}w4" 1.tr_lt#5.wave#1.SPD2017="SPD{&lowast}tr{&lowast}w5" 1.tr_lt#6.wave#1.SPD2017="SPD{&lowast}tr{&lowast}w6" 1.tr_lt#7.wave#1.SPD2017="SPD{&lowast}tr{&lowast}w7") legend(off) saving(coef_rate_SPD_SPDvoters, replace)
	
coefplot ife_rate_FDP, keep(1.tr_lt#2.wave#1.FDP2017 1.tr_lt#3.wave#1.FDP2017 1.tr_lt#4.wave#1.FDP2017 1.tr_lt#5.wave#1.FDP2017 1.tr_lt#6.wave#1.FDP2017 1.tr_lt#7.wave#1.FDP2017) baselevels  ///
	p1(msymbol(O))  levels(95 90)  ciopts(lwidth(*0.5 *2)) ///
	ytitle(Coefficient, size(small)) vertical yline(0) ylabel(-0.4(0.2)0.8) xtitle(, size(small)) xlabel(,labsize(vsmall) angle(45)) ///
	coeflabels (1.tr_lt#2.wave#1.FDP2017="FDP{&lowast}tr{&lowast}w2" 1.tr_lt#3.wave#1.FDP2017="FDP{&lowast}tr{&lowast}w3" 1.tr_lt#4.wave#1.FDP2017="FDP{&lowast}tr{&lowast}w4" 1.tr_lt#5.wave#1.FDP2017="FDP{&lowast}tr{&lowast}w5" 1.tr_lt#6.wave#1.FDP2017="FDP{&lowast}tr{&lowast}w6" 1.tr_lt#7.wave#1.FDP2017="FDP{&lowast}tr{&lowast}w7") legend(off) saving(coef_rate_FDP_FDPvoters, replace)	

coefplot ife_rate_Gr, keep(1.tr_lt#2.wave#1.Gr2017 1.tr_lt#3.wave#1.Gr2017 1.tr_lt#4.wave#1.Gr2017 1.tr_lt#5.wave#1.Gr2017 1.tr_lt#6.wave#1.Gr2017 1.tr_lt#7.wave#1.Gr2017) baselevels  ///
	p1(msymbol(O))  levels(95 90)  ciopts(lwidth(*0.5 *2)) ///
	ytitle(Coefficient, size(small)) vertical yline(0) ylabel(-0.4(0.2)0.8) xtitle(, size(small)) xlabel(,labsize(vsmall) angle(45)) ///
	coeflabels (1.tr_lt#2.wave#1.Gr2017="Gr{&lowast}tr{&lowast}w2" 1.tr_lt#3.wave#1.Gr2017="Gr{&lowast}tr{&lowast}w3" 1.tr_lt#4.wave#1.Gr2017="Gr{&lowast}tr{&lowast}w4" 1.tr_lt#5.wave#1.Gr2017="Gr{&lowast}tr{&lowast}w5" 1.tr_lt#6.wave#1.Gr2017="Gr{&lowast}tr{&lowast}w6" 1.tr_lt#7.wave#1.Gr2017="Gr{&lowast}tr{&lowast}w7") legend(off) saving(coef_rate_Gr_Grvoters, replace)	

coefplot ife_rate_LP, keep(1.tr_lt#2.wave#1.LP2017 1.tr_lt#3.wave#1.LP2017 1.tr_lt#4.wave#1.LP2017 1.tr_lt#5.wave#1.LP2017 1.tr_lt#6.wave#1.LP2017 1.tr_lt#7.wave#1.LP2017) baselevels  ///
	p1(msymbol(O))  levels(95 90)  ciopts(lwidth(*0.5 *2)) ///
	ytitle(Coefficient, size(small)) vertical yline(0) ylabel(-0.4(0.2)0.8) xtitle(, size(small)) xlabel(,labsize(vsmall) angle(45)) ///
	coeflabels (1.tr_lt#2.wave#1.LP2017="LP{&lowast}tr{&lowast}w2" 1.tr_lt#3.wave#1.LP2017="LP{&lowast}tr{&lowast}w3" 1.tr_lt#4.wave#1.LP2017="LP{&lowast}tr{&lowast}w4" 1.tr_lt#5.wave#1.LP2017="LP{&lowast}tr{&lowast}w5" 1.tr_lt#6.wave#1.LP2017="LP{&lowast}tr{&lowast}w6" 1.tr_lt#7.wave#1.LP2017="LP{&lowast}tr{&lowast}w7") legend(off) saving(coef_rate_LP_LPvoters, replace)		

graph combine coef_rate_CDU_CDUvoters.gph coef_rate_SPD_SPDvoters.gph coef_rate_FDP_FDPvoters.gph coef_rate_Gr_Grvoters.gph coef_rate_LP_LPvoters.gph, row(2)
graph export "Fig C3.png", replace		


* ------------------------------------------------------------------------------
* Check contamination of control units.
* ------------------------------------------------------------------------------
use "individual_level.dta", replace
set scheme plotplain
tsset id wave 
drop if tr_lt==0 // drop control unit and pick up Already treated states

* ------------------------------------------------------------------------------
* Figure C.4. Check for contamination: using respondents in already treated states and treated states as regression sample
eststo ife_rate_AfD_pbo: xtreg rate_AfD tr_lt##i.wave##AfD2017 AfD_pi_ tax_ego_ mig_ego_ polint_, fe 
estadd local fixedi "YES", replace
predict fe_rate_AfD_pbo, u
tabulate tr_lt if AfD2017==1, summarize(fe_rate_AfD_pbo)
margins if tr_lt==1 & AfD2017==1, exp(predict(xb) + 4.6089169) at(wave=(1(1)7))  noestimcheck saving(statetr, replace) 
margins if tr_lt==2 & AfD2017==1, exp(predict(xb) + 4.658399) at(wave=(1(1)7))  noestimcheck saving(stateatr, replace)
grstyle init
grstyle color p1 black
combomarginsplot statetr stateatr, labels("Treated states" "Already treated states") savefile(rate_AfD_pbo, replace)
mplotoffset using rate_AfD_pbo, xtitle("Wave") xlabel(1(1)7) xline(2.5,  lpattern(solid) lc(gs10%50) lwidth(vvvthick)) ytitle("Rating of AfD") ylabel(6 "0" 7 "1" 8 "2" 9 "3")  title("") ///
	legend(position(6) r(1)) plot1opts(lpattern(shortdash) lcolor("0 158 224") mcolor("0 158 224")) ci1opts(lcolor("0 158 224")) ///
	plot2opts(lcolor("0 158 224") mcolor("0 158 224")) ci2opts(lcolor("0 158 224")) saving(rate_AfD_AfDvoters_pbo, replace)  

* coefplot
coefplot ife_rate_AfD_pbo, keep(2.tr_lt#2.wave#1.AfD2017 2.tr_lt#3.wave#1.AfD2017 2.tr_lt#4.wave#1.AfD2017 2.tr_lt#5.wave#1.AfD2017 2.tr_lt#6.wave#1.AfD2017 2.tr_lt#7.wave#1.AfD2017) ///
	baselevels  p1(msymbol(O))  levels(95 90)  ciopts(lwidth(*0.5 *2)) ///
	ytitle(Coefficient, size(small)) vertical yline(0) ylabel(-0.8(0.2)0.4) xtitle(, size(small))  xlabel(,labsize(vsmall)) ///
	coeflabels (2.tr_lt#2.wave#1.AfD2017="AfD{&lowast}tr{&lowast}w2" 2.tr_lt#3.wave#1.AfD2017="AfD{&lowast}tr{&lowast}w3" 2.tr_lt#4.wave#1.AfD2017="AfD{&lowast}tr{&lowast}w4" 2.tr_lt#5.wave#1.AfD2017="AfD{&lowast}tr{&lowast}w5" 2.tr_lt#6.wave#1.AfD2017="AfD{&lowast}tr{&lowast}w6" 2.tr_lt#7.wave#1.AfD2017="AfD{&lowast}tr{&lowast}w7") legend(off) saving(coef_rate_AfD_AfDvoters_pbo, replace)

graph combine rate_AfD_AfDvoters_pbo.gph coef_rate_AfD_AfDvoters_pbo.gph, row(1)
graph export "Fog C4.png", replace

* ------------------------------------------------------------------------------
* Table C.2. Check for contamination: using respondents in already treated states and treated states as regression sample
esttab ife_rate_AfD_pbo ///
	using "Table C2.rtf", b(2) se(2) replace ///
	scalars ("N Observations" "N_g Number of respondents" "fixedi Individual FE" ) sfmt(0) ///
	label wide note onecell nobaselevels  noomitted nonumbers  lines varwidth(30) ///
	coeflabels(2.wave "wave 2" 3.wave "wave 3" 4.wave "wave 4" 5.wave "wave 5" 6.wave "wave 6" 7.wave "wave 7" ///
	2.tr_lt#2.wave "tr * wave 2" 2.tr_lt#3.wave "tr * wave 3" 2.tr_lt#4.wave "tr * wave 4" 	2.tr_lt#5.wave "tr * wave 5" 2.tr_lt#6.wave "tr * wave 6" 2.tr_lt#7.wave "tr * wave 7" ///
	2.wave#1.AfD2017 "AfD * wave 2" 3.wave#1.AfD2017 "AfD * wave 3" 4.wave#1.AfD2017 "AfD * wave 4" ///
	5.wave#1.AfD2017 "AfD * wave 5" 6.wave#1.AfD2017 "AfD * wave 6" 7.wave#1.AfD2017 "AfD * wave 7" ///
	2.tr_lt#2.wave#1.AfD2017 "tr * AfD * wave 2" 2.tr_lt#3.wave#1.AfD2017 "tr * AfD * wave 3" 2.tr_lt#4.wave#1.AfD2017 "tr * AfD * wave 4" 	///
	2.tr_lt#5.wave#1.AfD2017 "tr * AfD * wave 5" 2.tr_lt#6.wave#1.AfD2017 "tr * AfD * wave 6" 2.tr_lt#7.wave#1.AfD2017 "tr * AfD * wave 7") ///
	order (2.wave 3.wave 4.wave 5.wave 6.wave 7.wave 2.tr_lt#2.wave 2.tr_lt#3.wave 2.tr_lt#4.wave 2.tr_lt#5.wave 2.tr_lt#6.wave 2.tr_lt#7.wave ///
	2.wave#1.AfD2017 3.wave#1.AfD2017 4.wave#1.AfD2017 5.wave#1.AfD2017  6.wave#1.AfD2017 7.wave#1.AfD2017 ///
	2.tr_lt#2.wave#1.AfD2017  2.tr_lt#3.wave#1.AfD2017 2.tr_lt#4.wave#1.AfD2017 2.tr_lt#5.wave#1.AfD2017 2.tr_lt#6.wave#1.AfD2017 2.tr_lt#7.wave#1.AfD2017 ) ///
	mtitles("Model 1") modelwidth(4) ///
	note ("Note: DV of Model 1: Rating of AfD." ///
	"Entries are coefficients of fixed effect model.") ///
	title ("Table C.2. Check for contamination: using respondents in already treated states and treated states as regression sample") 	
	
